﻿using RpcModel;
using RpcModel.RemoteLock;
using RpcSync.Service.Interface;

namespace RpcSync.Service.Event
{
    /// <summary>
    /// 远程锁服务
    /// </summary>
    internal class RpcLockEvent : RpcClient.Interface.IRpcApiService
    {
        private ISyncLockService _Service;

        public RpcLockEvent(ISyncLockService service)
        {
            this._Service = service;
        }


        /// <summary>
        /// 重置锁
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="source"></param>
        public void ReleaseLock(ReleaseLock obj, MsgSource source)
        {
            this._Service.ReleaseLock(obj, source.ServerId);
        }
        /// <summary>
        /// 获取锁状态
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public ApplyLockRes GetLockStatus(GetLockStatus obj)
        {
            return this._Service.GetLockStatus(obj);
        }
        /// <summary>
        /// 申请锁
        /// </summary>
        /// <param name="apply"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public ApplyLockRes ApplyLock(ApplyLock apply, MsgSource source)
        {
            return this._Service.ApplyLock(apply, source.ServerId);
        }
    }
}
